home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Internet / TurboTCP 2.1 ƒ / PP MiniTelnet source / CTerminalPane.h < prev    next >
Encoding:
Text File  |  1995-01-19  |  3.2 KB  |  123 lines  |  [TEXT/MMCC]

  1. //
  2. // CTerminalPane.h
  3. //
  4. //    TerminalPane library
  5. //    Terminal display pane
  6. //    PowerPlant version
  7. //
  8. //    Copyright © 1993-95, FrostByte Design / Eric Scouten
  9. //
  10.  
  11. #pragma once
  12.  
  13. #include <LPeriodical.h>
  14. #include <LView.h>
  15.  
  16.  
  17. //***********************************************************
  18.  
  19. class CTerminalPane : public LView, public LPeriodical {
  20.  
  21. // This class provides a rudimentary terminal emulator. It’s nothing fancy or snazzy.
  22. // It doesn’t do VT100; it doesn’t do scrollback; it doesn’t handle any kind of formatting.
  23.  
  24. public:
  25.     enum { class_ID = 'TERM' };
  26.     static CTerminalPane* CreateTerminalPaneStream(LStream* inStream);
  27.                 CTerminalPane(LStream* inStream);
  28.  
  29.     // configuration
  30.     
  31.     virtual void    SetBlinking(Boolean blinkMode);
  32.     virtual void    DisableKeyScroll(Boolean disable);
  33.  
  34.     // terminal behaviors
  35.  
  36.     virtual void    DoClearScreen();
  37.     virtual void    DoWriteChar(char theChar);
  38.     virtual void    DoWriteStr(char* theStr);
  39.     virtual void    DoWriteBfr(char* theStr, short theSize);
  40.     virtual void    DoWriteCharNum(char theChar, char leftBracket, char rightBracket);
  41.     virtual void    DoEraseChar();
  42.     virtual void    DoEraseLine();
  43.     virtual void    ScrollToSelection();
  44.  
  45.     // drawing
  46.     
  47. protected:
  48.     virtual void    DrawSelf();    
  49.     
  50.     // scrolling
  51.     
  52. //    virtual void    DoKeyDown(char theChar, Byte keyCode, EventRecord* macEvent);
  53.     
  54.     // internal blinking cursor support
  55.     
  56.     virtual void    Activate();
  57.     virtual void    Deactivate();
  58.     virtual void    SpendTime(const EventRecord& inMacEvent);
  59. //    virtual void    Dawdle(long* maxSleep);
  60. //    virtual Boolean    BecomeGopher(Boolean fBecoming);
  61.     
  62.     // internal screen behaviors
  63.     
  64.     virtual void    ClearToEOL(short col, short line);
  65.     virtual void    ClearToEOS(short col, short line);
  66.     virtual void    ScrollTerm();
  67.     virtual void    InvalCharRect(short left, short top, short right, short bottom);
  68.     virtual void    CursorMoved();
  69.     virtual void    CalcCharRect(short left, short top, short right, short bottom, Rect& theRect);
  70.     virtual void    InvertCursor(short col, short line);
  71.  
  72.  
  73.     // define the size of the screen
  74.     //    (*sigh*… someday this won’t be hard-coded)
  75.     
  76.     enum {
  77.         maxX = 80,                            // width of screen
  78.         maxY = 24                            // height of screen
  79.     };
  80.  
  81.  
  82.     // data members
  83.     
  84. protected:
  85.     char            theScreen[maxY][maxX];            // contents of the screen
  86.     short        theColumn;                    // terminal cursor column number
  87.     short        theLine;                        // terminal cursor line number
  88.     Boolean        blinkCursor;                    // cursor blinking is enabled
  89.     Boolean        cursorVis;                    // cursor is inverted
  90.     Boolean        disableKeyScroll;                // disable Home/End/PageUp/PageDown
  91.     short        lastCursorCol;                    // position of displayed cursor
  92.     short        lastCursorLine;
  93.     long            lastCursorTick;                    // time at last cursor flash
  94.     short        charsToInvalLine;                // trigger optimization to invalidate entire line at once
  95.  
  96.  
  97.     // misc. display parameters
  98.     
  99.     enum {
  100.         pixelsX = 6,                    // default font char width (Monaco 9)
  101.         pixelsY = 11,                    // default font char height
  102.         
  103.         offsetX = 4,                    // horizontal offset from screen edge
  104.         offsetY = 4,                    // vertical offset from screen edge
  105.         
  106.         sizeX = 488,                    // 80 columns * 6 pixels + 8 margin
  107.         sizeY = 272                    // 24 rows * 11 pixels + 8 margin
  108.     };
  109.  
  110.     enum {                                        // standard ASCII keycodes
  111.         charNUL = 0,
  112.         charBEL = 7,
  113.         charBS,
  114.         charHT,
  115.         charLF,
  116.         charVT,
  117.         charFF,
  118.         charCR,
  119.         charDEL = 127
  120.     };
  121.  
  122. };
  123.